package csu.rjxyg.factory.core;

import csu.rjxyg.action.constant.ServiceConstant;
import csu.rjxyg.action.constant.CourseConstant;
import csu.rjxyg.action.constant.UserConstant;
import csu.rjxyg.dao.BaseDaoAdapter;

public class DaoFactory {
	
	private static BeanFactory factory = BeanFactory.getBeanFactory();;
	
	@Deprecated
	public static BaseDaoAdapter getCourseDao() {
		BaseDaoAdapter courseDao = (BaseDaoAdapter) factory.getBean(ServiceConstant.DAO_BASE);
		courseDao.setCollectionName(CourseConstant.COLLECTION_NAME);
		return courseDao;
	}
	
	@Deprecated
	public static BaseDaoAdapter getUserDao() {
		BaseDaoAdapter userDao = (BaseDaoAdapter) factory.getBean(ServiceConstant.DAO_BASE);
		userDao.setCollectionName(UserConstant.COLLECTION_NAME);
		return userDao;
	}
	
	public static BaseDaoAdapter getDaoByColName(String CollectionName) {
		BaseDaoAdapter baseDao = (BaseDaoAdapter) factory.getBean(ServiceConstant.DAO_BASE);
		baseDao.setCollectionName(CollectionName);
		return baseDao;
	}
}
